package com.lmk.homework;

import java.util.ArrayList;

public class Student{
    String name;
    int age;
    String se;
    public static void main(String[] args) {
        ArrayList<Student> arr=new ArrayList<>();
        addStudent(arr);
        printS(arr);
        getMax(arr);
    }
    private static void getMax(ArrayList<Student> arr) {
        int num=arr.get(0).age;
        int index=0;
        for(int j=0;j<arr.size();j++)
        {

            if(num<arr.get(j).age)
            {
                num=arr.get(j).age;
                index=j;
            }
        }
        arr.get(index).name="小猪佩奇";
        System.out.println(num);

        System.out.println(arr.get(index).name);
        for(int q=0;q<arr.size();q++)
        {
            System.out.println(arr.get(q).name+" "+arr.get(q).age+" "+arr.get(q).se);
        }

    }

    private static void printS(ArrayList<Student> arr) {
        for(int i=0;i<arr.size();i++)
        {

            System.out.println(arr.get(i).name+" "+arr.get(i).age+" "+arr.get(i).se);
        }

    }
    private static void addStudent(ArrayList<Student> arr) {
        Student s1=new Student();
        s1.name="马虎腾";
        s1.age=18;
        s1.se="男";

        Student s2=new Student();
        s2.name="麻婆苍穹";
        s2.age=34;
        s2.se="女";

        Student s3=new Student();
        s3.name="哇哈哈";
        s3.age=25;
        s3.se="男";

        arr.add(s1);
        arr.add(s2);
        arr.add(s3);
    }
}
